﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AbnormalRept.aspx.cs" Inherits="FX.CC.Andon.WebSite.ReportManage.AbnormalRept" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>异常情况报表</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table>
            <tr>
                <td align="right">
                    开始日期：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="BizDateFrom" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td align="right">
                    结束日期：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="BizDateEnd" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td align="right">
                    异常类别：
                </td>
                <td style="width: 150px;" align="left">
                    <div id="ETypeCode" name="ETypeCode" class="mini-combobox" style="width: 150px;"
                        popupwidth="300" textfield="ETypeName" valuefield="ETypeCode" url="../Service/BasicDataManageHandler.ashx?action=GetETypeListByCombobox">
                        <div property="columns">
                            <div header="异常类别编号" field="ETypeCode">
                            </div>
                            <div header="异常类别名称" field="ETypeName">
                            </div>
                        </div>
                    </div>
                </td>
                <td>
                    <a class="mini-button" iconcls="icon-search" onclick="search()">查 询</a>
                </td>
            </tr>
            <tr>
                <td align="right">
                    产线：
                </td>
                <td style="width: 150px;" align="left">
                    <div id="LineID" name="LineID" class="mini-combobox" style="width: 150px;" popupwidth="400"
                        onvaluechanged="onLineIDChanged" textfield="LineName" valuefield="LineID" url="../Service/BasicDataManageHandler.ashx?action=GetLineListByCombobox">
                        <div property="columns">
                            <div header="产线编号" field="LineCode" width="40%">
                            </div>
                            <div header="产线名称" field="LineName" width="60%">
                            </div>
                        </div>
                    </div>
                </td>
                <td align="right">
                    设备：
                </td>
                <td style="width: 150px;" align="left">
                    <div id="EqID" name="EqID" class="mini-combobox" style="width: 150px;" popupwidth="400"
                        textfield="EqName" valuefield="EqID">
                        <div property="columns">
                            <div header="设备编号" field="EqCode" width="40%">
                            </div>
                            <div header="设备名称" field="EqName" width="60%">
                            </div>
                        </div>
                    </div>
                </td>
                <td align="right">
                    产品：
                </td>
                <td style="width: 150px;" align="left">
                    <div id="PrdID" name="PrdID" class="mini-combobox" style="width: 150px;" popupwidth="400"
                        textfield="PrdName" valuefield="PrdID">
                        <div property="columns">
                            <div header="产品编号" field="PrdCode" width="40%">
                            </div>
                            <div header="产品名称" field="PrdName" width="60%">
                            </div>
                        </div>
                    </div>
                </td>
                <td>
                    <a class="mini-button" iconcls="icon-reset" onclick="reset()">重 置</a>
                </td>
            </tr>
            <tr>
                <td align="right">
                    作废标记：
                </td>
                <td style="width: 150px;" align="left">
                    <select id="IsCancle" class="mini-radiobuttonlist">
                        <option value="0">未作废</option>
                        <option value="1">已作废</option>
                    </select>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" iconcls="icon-add" onclick="addRemark();" plain="true">添加备注</a>
                    <a class="mini-button" iconcls="icon-excel" onclick="ExportExcel();" plain="true">导出Excel</a>
                    <a class="mini-button" iconcls="icon-signin" onclick="signin();" plain="true">异常签到详情</a>
                    <a class="mini-button" iconcls="icon-send" onclick="send();" plain="true">发信明细详情</a>
                    <span class="separator"></span><a class="mini-button" onclick="close()" iconcls="icon-close"
                        plain="true">关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="EventID"
            sizelist="[10,20,50,100]" pagesize="20" contextmenu="#gridMenu">
            <div property="columns">
                <div type="indexcolumn">
                </div>
                <div field="IsCancle" width="70" headeralign="center" allowsort="true" renderer="onIsCancleRenderer">
                    作废标记
                </div>
                <div field="PrdCode" width="120" headeralign="center" allowsort="true">
                    产品编号
                </div>
                <div field="PrdName" width="180" headeralign="center" allowsort="true">
                    产品名称
                </div>
                <div field="LineName" width="140" headeralign="center" allowsort="true">
                    产线名称
                </div>
                <div field="EqCode" width="110" headeralign="center" allowsort="true">
                    设备编号
                </div>
                <div field="EqName" width="250" headeralign="center" allowsort="true">
                    设备名称
                </div>
                <div field="StartTime" width="130" headeralign="center" allowsort="true" dateformat="yyyy-MM-dd HH:mm:ss">
                    异常触发时间
                </div>
                <div field="EndTime" width="130" headeralign="center" allowsort="true" dateformat="yyyy-MM-dd HH:mm:ss">
                    异常解除时间
                </div>
                <div field="ElapsedTime" width="100" headeralign="center" allowsort="true">
                    持续时间（分钟）
                </div>
                <div field="ETypeName" width="150" headeralign="center" allowsort="true">
                    异常原因
                </div>
                <div field="DetailCode" width="110" headeralign="center" allowsort="true">
                    异常明细编号
                </div>
                <div field="DetailName" width="200" headeralign="center" allowsort="true">
                    异常明细名称
                </div>
                <div field="StartUserFullName" width="120" headeralign="center" allowsort="true">
                    操作人
                </div>
                <div field="EndUserFullName" width="120" headeralign="center" allowsort="true">
                    处理人员
                </div>
                <div field="Remark" width="400" headeralign="center" allowsort="false">
                    备注
                </div>
            </div>
        </div>
        <ul id="gridMenu" class="mini-contextmenu" onbeforeopen="onBeforeOpen">
            <li id="AbnormalDetail" iconcls="icon-view" onclick="AbnormalDetailClick()">异常签到详情</li>
            <li id="SenderDetail" iconcls="icon-view" onclick="SenderDetailClick()">发信明细详情</li>
        </ul>
    </div>
    <iframe id="exportIFrame" style="display: none;"></iframe>
    <script type="text/javascript">
        mini.parse();
        mini.get("IsCancle").setValue("0");
        var now = new Date();
        var nowYear = now.getFullYear();
        var nowMonth = now.getMonth();
        var bizDateFrom = mini.get("BizDateFrom");
        bizDateFrom.setValue(new Date(nowYear, nowMonth, 1));
        var bizDateEnd = mini.get("BizDateEnd");
        bizDateEnd.setValue(new Date());
        var grid = mini.get("datagrid1");
        var EqID = mini.get("EqID");
        var PrdID = mini.get("PrdID");
        PrdID.setUrl("../service/BasicDataManageHandler.ashx?action=GetProductListByCombobox");
        grid.setUrl("../service/ReportManageHandler.ashx?action=GetAbnormalReptList");
        grid.load({ BizDateFrom: mini.get("BizDateFrom").getFormValue(), BizDateEnd: mini.get("BizDateEnd").getFormValue(), IsCancle: mini.get("IsCancle").getValue() });
        function onLineIDChanged(e) {
            EqID.setUrl("../service/BasicDataManageHandler.ashx?action=GetEquipmentListByCombobox&LineID=" + e.value);
        }
        function onBeforeOpen(e) {
            var grid = mini.get("datagrid1");
            var menu = e.sender;
            var row = grid.getSelected();
            var rowIndex = grid.indexOf(row);
            if (!row) {
                e.cancel = true;
                //阻止浏览器默认右键菜单
                e.htmlEvent.preventDefault();
                return;
            }
            var AbnormalDetail = mini.get("AbnormalDetail", menu);
            var SenderDetail = mini.get("SenderDetail", menu);
            AbnormalDetail.show();
            SenderDetail.show();
        }

        function signin() {
            AbnormalDetailClick();
        }
        function send() {
            SenderDetailClick();
        }

        function AbnormalDetailClick() {
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: "ReportManage/AbnormalDetail.aspx",
                    title: "异常签到详情", width: 800, height: 400,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "view", EventID: row.EventID };
                        iframe.contentWindow.SetData(data);
                    },
                    ondestroy: function (action) {
                    }
                });

            } else {
                mini.alert("请选中一条需要查看的记录!");
            }
        }
        function SenderDetailClick() {
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: "ReportManage/SenderDetail.aspx",
                    title: "发信明细详情", width: 800, height: 400,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "view", EventID: row.EventID };
                        iframe.contentWindow.SetData(data);
                    },
                    ondestroy: function (action) {
                    }
                });

            } else {
                mini.alert("请选中一条需要查看的记录!");
            }
        }
        function search() {
            var BizDateFrom = mini.get("BizDateFrom").getFormValue();
            var BizDateEnd = mini.get("BizDateEnd").getFormValue();
            var LineID = mini.get("LineID").getValue();
            var EqID = mini.get("EqID").getValue();
            var ETypeCode = mini.get("ETypeCode").getValue();
            var PrdID = mini.get("PrdID").getValue();
            var IsCancle = mini.get("IsCancle").getValue();
            grid.load({ BizDateFrom: BizDateFrom, BizDateEnd: BizDateEnd, LineID: LineID, EqID: EqID, ETypeCode: ETypeCode, PrdID: PrdID, IsCancle: IsCancle });
        }

        //回车键事件
        function onKeyEnter() {
            search();
        }

        function addRemark() {
            var rows = grid.getSelected();
            if (rows) {
                mini.open({
                    url: "ReportManage/EditEventRecInfoForm.aspx",
                    title: "添加备注", width: 530, height: 290,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", EventID: rows.EventID };
                        iframe.contentWindow.SetData(data);

                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });
            }
            else {
                mini.alert("请选中一条您需要添加的记录!");
            }
        }

        function reset() {
            var now = new Date();
            var nowYear = now.getFullYear();
            var nowMonth = now.getMonth();
            var bizDateFrom = mini.get("BizDateFrom");
            bizDateFrom.setValue(new Date(nowYear, nowMonth, 1));
            var bizDateEnd = mini.get("BizDateEnd");
            bizDateEnd.setValue(new Date());
            mini.get("LineID").setValue("");
            mini.get("EqID").setData("[]");
            mini.get("EqID").setValue("");
            mini.get("ETypeCode").setValue("");
            mini.get("PrdID").setValue("");
            mini.get("IsCancle").setValue("0");
        }
        function ExportExcel() {
            var BizDateFrom = mini.get("BizDateFrom").getFormValue();
            var BizDateEnd = mini.get("BizDateEnd").getFormValue();
            var LineID = mini.get("LineID").getValue();
            var EqID = mini.get("EqID").getValue();
            var ETypeCode = mini.get("ETypeCode").getValue();
            var PrdID = mini.get("PrdID").getValue();
            var IsCancle = mini.get("IsCancle").getValue();
            var url = "../Service/ReportManageHandler.ashx?action=ExportAbnormalRept&BizDateFrom=" + BizDateFrom + "&BizDateEnd=" + BizDateEnd + "&LineID=" + LineID + "&EqID=" + EqID + "&ETypeCode=" + ETypeCode + "&PrdID=" + PrdID + "&IsCancle=" + IsCancle;
            var exportIFrame = document.getElementById("exportIFrame");
            exportIFrame.src = url;
        }
        function onIsCancleRenderer(e) {
            if (e.value == "0") { return "<span style=\"color: Green;font-weight:bold;\">未作废</span>"; }
            else if (e.value == "1") { return "<span style=\"color: Red;font-weight:bold;\">已作废</span>"; }
            else { return ""; }
        }
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function close() {
            CloseWindow("close");
        }
    </script>
</body>
</html>
